<?php

namespace SisesporteAdmin\Form;

use Zend\Form\Form;
use \SisesporteAdmin\Filter\AuthFilter,
    Zend\Form\Element\Captcha,
    Zend\Captcha\Image as CaptchaImage;

class AuthForm extends Form {

    public function __construct($name = null) {
        parent::__construct('autenticacao');

        $this->setAttribute('method', 'post');
        $this->setInputFilter(new AuthFilter());

        $this->add(array(
            'name' => 'noLogin',
            'options' => array(
                'type' => 'text',
                'label' => 'Matrícula:'
            ),
            'attributes' => array(
                'placeholder' => 'Entre com sua matricula',
                'maxlength' => '10'
            )
        ));
        $this->add(array(
            'name' => 'noSenha',
            'options' => array(
                'type' => 'Password',
                'label' => 'Senha:'
            ),
            'attributes' => array(
                'type' => 'password',
                'placeholder' => 'Entre com sua senha'
            )
        ));

        $dirdata = './data';

        //pass captcha image options
        $captchaImage = new CaptchaImage(array(
                    'font' => $dirdata . '/fonts/arial.ttf',
                    'width' => 250,
                    'height' => 100,
                    'dotNoiseLevel' => 40,
                    'lineNoiseLevel' => 3)
        );
        $captchaImage->setImgDir($dirdata . '/captcha');
        $captchaImage->setImgUrl('/captcha');
        $captchaImage->setName('captcha');
        
        //add captcha element...
        $this->add(array(
            'type' => 'Zend\Form\Element\Captcha',
            'name' => 'captcha',
            'options' => array(
                'label' => 'Informe o Código: ',
                'captcha' => $captchaImage,
            ),
        ));

        $this->add(array(
            'name' => 'submit',
            'type' => 'Zend\Form\Element\Submit',
            'attributes' => array(
                'value' => 'Entrar',
                'class' => 'btn btn-success'
            )
        ));
    }

}
